/*
 *   Copyright 2008 Luca Bellonda <lbellonda@gmail.com>
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Library General Public License as
 *   published by the Free Software Foundation; either version 2 or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details
 *
 *   You should have received a copy of the GNU Library General Public
 *   License along with this program; if not, write to the
 *   Free Software Foundation, Inc.,
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#ifndef EXTENDERTUTORIAL_H
#define EXTENDERTUTORIAL_H

#include <plasma/applet.h>
#include <plasma/popupapplet.h>
#include <plasma/dataengine.h>
#include <QWebFrame>

namespace Plasma
{
class WebView;
} // namespace Plasma

class DBusApplet : public Plasma::PopupApplet
{
    Q_OBJECT
public:
    DBusApplet(QObject *parent, const QVariantList &args);
    ~DBusApplet();

    void init();
    virtual void constraintsEvent(Plasma::Constraints constraints);


protected:
    void paintInterface(QPainter *painter,
                        const QStyleOptionGraphicsItem *option,
                        const QRect& contentsRect);
    QGraphicsLinearLayout* mainLayout();
public slots:
    void connectFrame(QWebFrame *frame);
    void dataUpdated(const QString& source, const Plasma::DataEngine::Data &data);
    void reload(const QString &selection);

    void populateJavaScriptWindowObject();

private:

    QString readDataFile(const QString inputPath);

    Plasma::DataEngine *m_DBusEngine;
    QStringList m_lastDataSession;
    QStringList m_lastDataSystem;
    QString m_template;
    QString m_src;

    Plasma::WebView *m_info;
    QGraphicsLinearLayout *m_mainLayout;
    Qt::Orientation m_orientation;
private slots:
    void updateView();
    void    loadFinished(bool success);
    //void scanEnd();
};

K_EXPORT_PLASMA_APPLET(dbusapplet, DBusApplet)

#endif